package com.ruoyi.web.controller.biz;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.biz.BmMemberReport;
import com.ruoyi.system.service.biz.IBmMemberReportService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 会员费用汇总信息Controller
 * 
 * @author ruoyi
 * @date 2022-11-18
 */
@Controller
@RequestMapping("/biz/report")
public class BmMemberReportController extends BaseController
{
    private String prefix = "biz/report";

    @Autowired
    private IBmMemberReportService bmMemberReportService;

    @RequiresPermissions("biz:report:view")
    @GetMapping()
    public String report()
    {
        return prefix + "/report";
    }

    /**
     * 查询会员费用汇总信息列表
     */
    @RequiresPermissions("biz:report:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BmMemberReport bmMemberReport)
    {
        startPage();
        List<BmMemberReport> list = bmMemberReportService.selectBmMemberReportList(bmMemberReport);
        return getDataTable(list);
    }

    /**
     * 导出会员费用汇总信息列表
     */
    @RequiresPermissions("biz:report:export")
    @Log(title = "会员费用汇总信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BmMemberReport bmMemberReport)
    {
        List<BmMemberReport> list = bmMemberReportService.selectBmMemberReportList(bmMemberReport);
        ExcelUtil<BmMemberReport> util = new ExcelUtil<BmMemberReport>(BmMemberReport.class);
        return util.exportExcel(list, "会员费用汇总信息数据");
    }

    /**
     * 新增会员费用汇总信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存会员费用汇总信息
     */
    @RequiresPermissions("biz:report:add")
    @Log(title = "会员费用汇总信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BmMemberReport bmMemberReport)
    {
        return toAjax(bmMemberReportService.insertBmMemberReport(bmMemberReport));
    }

    /**
     * 修改会员费用汇总信息
     */
    @RequiresPermissions("biz:report:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        BmMemberReport bmMemberReport = bmMemberReportService.selectBmMemberReportById(id);
        mmap.put("bmMemberReport", bmMemberReport);
        return prefix + "/edit";
    }

    /**
     * 修改保存会员费用汇总信息
     */
    @RequiresPermissions("biz:report:edit")
    @Log(title = "会员费用汇总信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BmMemberReport bmMemberReport)
    {
        return toAjax(bmMemberReportService.updateBmMemberReport(bmMemberReport));
    }

    /**
     * 删除会员费用汇总信息
     */
    @RequiresPermissions("biz:report:remove")
    @Log(title = "会员费用汇总信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bmMemberReportService.deleteBmMemberReportByIds(ids));
    }
}
